package com.catal.framework.data;

import java.util.ArrayList;
import java.util.List;

public class Or_bak extends Condition{

	protected Condition leftCondition;
	
	protected List<Condition> rightItems = new ArrayList<Condition>();
	
	public Or_bak() {
		super();
	}
	
//	/**
//	 * 构造方法 or左边条件无参数
//	 * @param leftItem 	or左边条件的 列
//	 * @param operType	or左边条件的操作
//	 * @param orCondition or右边的条件
//	 */
//	public Or(String leftItem, String operType,  Condition orCondition) {
//		super(leftItem, operType);
//	}
//	
//	/**
//	 * 构造方法 or左边条件1参数
//	 * @param leftItem 	or左边条件的 列
//	 * @param operType	or左边条件的操作
//	 * @param value1	or左边条件的参数值1
//	 * @param orCondition or右边的条件
//	 */
//	public Or(String leftItem, String operType, String value1,  Condition orCondition) {
//		super(leftItem, operType, value1);
//	}
//	
//	/**
//	 * 构造方法 or左边条件2参数
//	 * @param leftItem 	or左边条件的 列
//	 * @param operType	or左边条件的操作
//	 * @param value1	or左边条件的参数值1
//	 * @param value2	or左边条件的参数值2
//	 * @param orCondition or右边的条件
//	 */
//	public Or(String leftItem, String operType, String value1, String value2,  Condition orCondition) {
//		super(leftItem, operType, value1,value2);
//	}

	/**
	 * 
	 * @param leftCondition	or左边源条件
	 * @param orCondition	or右边的条件
	 */
	public Or_bak(Condition leftCondition, Condition orCondition){
//		this.leftItem = leftCondition.leftItem;
//		this.operType = leftCondition.operType;
//		this.value1 = leftCondition.value1;
//		this.value2 = leftCondition.value2;
		this.leftCondition = leftCondition;
//		this.addRightItem(orCondition);
	}
	
//	@Override
//	public void addRightItem(Condition condition) {
//		this.rightItems.add(condition);
//	}

	public String toString(){
		StringBuffer buffer = new StringBuffer("((");
		buffer.append(this.leftCondition.toString() + ")");
		for(Condition condition : rightItems){
			buffer.append(" OR ").append("("+condition+")");
		}
		buffer.append(")");
		return buffer.toString();
	}
	
	public static void main(String[] args) {
		Condition con1 = new Condition("t.a", ConditionOperSign.GE,"1");
		Condition con2 = new Condition("t.a", ConditionOperSign.LE,"10");
		And and = new And(con1, con2);
		Condition con3 = new Condition("t.b", ConditionOperSign.BETWEEN, "10","100");
		Or or = new Or(and, con3);
		System.out.println(or);
	}
}
